{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.9 64-bit ('CSQA')",
   "metadata": {
    "interpreter": {
     "hash": "90f16fc473da99dae7f28739a8f74963c792de6ae40ab2f78d57652613f3a601"
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "d:\\CODE\\Project\\Smart-Writing\\Text Classification\n",
      " ������ D �еľ��� Files\n",
      " �������к��� C14D-581B\n",
      "\n",
      " d:\\CODE\\Project\\Smart-Writing\\Text Classification ��Ŀ¼\n",
      "\n",
      "21/03/10  ���� 09:46    <DIR>          .\n",
      "21/03/10  ���� 09:46    <DIR>          ..\n",
      "21/01/26  ���� 03:50             1,955 .gitignore\n",
      "21/03/06  ���� 07:46    <DIR>          .vscode\n",
      "21/03/11  ���� 11:13    <DIR>          CODE\n",
      "21/03/10  ���� 10:02    <DIR>          DATA\n",
      "21/03/10  ���� 09:44               706 readme.md\n",
      "21/03/10  ���� 08:37    <DIR>          Shell\n",
      "               2 ���ļ�          2,661 �ֽ�\n",
      "               6 ��Ŀ¼ 137,458,528,256 �����ֽ�\n"
     ]
    }
   ],
   "source": [
    "%cd ../\n",
    "!dir"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "f1 = open('DATA/result/task_result.json', 'r', encoding='utf-8')\n",
    "f2 = open('DATA/swtc/smartwrite_test.json', 'r', encoding='utf-8')\n",
    "import json\n",
    "j1 = json.load(f1)\n",
    "j2 = json.load(f2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "count_dict = {}\n",
    "same, total = 0, 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "for c1, c2 in zip(j1, j2):\n",
    "    if c1['topics'] == c2['topics']:\n",
    "        same += 1\n",
    "    else:\n",
    "        count_dict[c2['topics']] = count_dict.get(c2['topics'], 0) + 1\n",
    "    total += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "{'劳动、人事、监察': 44,\n",
       " '综合政务': 58,\n",
       " '城乡建设、环境保护': 43,\n",
       " '国民经济管理、国有资产监管': 31,\n",
       " '国防': 5,\n",
       " '国务院组织机构': 11,\n",
       " '市场监管、安全生产监管': 31,\n",
       " '科技、教育': 20,\n",
       " '财政、金融、审计': 26,\n",
       " '农业、林业、水利': 21,\n",
       " '公安、安全、司法': 18,\n",
       " '国土资源、能源': 14,\n",
       " '文化、广电、新闻出版': 14,\n",
       " '工业、交通': 30,\n",
       " '民族、宗教': 5,\n",
       " '卫生、体育': 9,\n",
       " '商贸、海关、旅游': 28,\n",
       " '民政、扶贫、救灾': 22,\n",
       " '人口与计划生育、妇女儿童工作': 4,\n",
       " '港澳台侨工作': 2}"
      ]
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "count_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "{'劳动、人事、监察': 10.091743119266056,\n",
       " '综合政务': 13.302752293577983,\n",
       " '城乡建设、环境保护': 9.862385321100918,\n",
       " '国民经济管理、国有资产监管': 7.110091743119266,\n",
       " '国防': 1.146788990825688,\n",
       " '国务院组织机构': 2.522935779816514,\n",
       " '市场监管、安全生产监管': 7.110091743119266,\n",
       " '科技、教育': 4.587155963302752,\n",
       " '财政、金融、审计': 5.963302752293578,\n",
       " '农业、林业、水利': 4.81651376146789,\n",
       " '公安、安全、司法': 4.128440366972478,\n",
       " '国土资源、能源': 3.211009174311927,\n",
       " '文化、广电、新闻出版': 3.211009174311927,\n",
       " '工业、交通': 6.8807339449541285,\n",
       " '民族、宗教': 1.146788990825688,\n",
       " '卫生、体育': 2.064220183486239,\n",
       " '商贸、海关、旅游': 6.422018348623854,\n",
       " '民政、扶贫、救灾': 5.045871559633028,\n",
       " '人口与计划生育、妇女儿童工作': 0.9174311926605505,\n",
       " '港澳台侨工作': 0.45871559633027525}"
      ]
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "source": [
    "{k: v/(total-same)*100 for k, v in count_dict.items()}"
   ]
  }
 ]
}